package com.egg.auth.enums.user;


import com.egg.common.swagger.annotation.SwaggerDisplayAnnotation;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 状态枚举类
 *
 * @author east
 */
@Getter
@SwaggerDisplayAnnotation
@AllArgsConstructor
public enum UserStateEnum {


    STOP("停用", "stop"),
    ENABLED("启用", "enabled"),
    ;


    private String message;
    private String code;


    public static boolean isInvalid(String code) {
        if (null == code) {
            return true;
        }
        return !Arrays.stream(values()).anyMatch(o -> Objects.equals(code, o.getCode()));
    }

    @Override
    public String toString() {
        return message + ":" + code;
    }
}
